package cn.wx.scholar.neo4j.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
/*import org.springframework.data.neo4j.repository.GraphRepository;*/
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import cn.wx.scholar.neo4j.entity.Neo4jBook;

@Repository
public interface BookRepository extends Neo4jRepository<Neo4jBook,Long> {
	
	/**
	 * //查询某个专家编写的所有图书，带分页
	 * @param id
	 * @param pageable
	 * @return
	 */
	@Query(value = "match(e:expert)-[r:write1]-(b:book) where ID(e)={ExpertId} return b order by b.fPublishDate desc",
			countQuery = "match(e:expert)-[r:write1]-(b:book) where ID(e)={ExpertId} return count(ID(b))")
	Page<Neo4jBook> findAllBooksByExpertId(@Param("ExpertId") Long ExpertId,Pageable pageable);
	
	/*@Query("match(b:book) where ID(b)={id} return b")
	Neo4jBook findBookDetailById(@Param("id") Long id);	//查询某本图书的详情
*/}
